:root {
    --bg-color: #212121;
    --sidebar-bg: #181818;
    --text-color: #ececec;
    --input-bg: #2f2f2f;
    --icon-color: #b4b4b4;
    --content-max-width: 900px;
    --mobile-header-height: 56px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    padding-right: 0px;
    padding-top: 0px;
    padding-bottom: 0px;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1;
    overflow-y: auto;
    /* Allow scrolling if list is long */
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    margin-bottom: 10px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: calc(100% - 10px);
    margin-bottom: 20px;
}

.sidebar-bottom {
    padding: 10px 8px;
    border-top: 1px solid #333;
}

.model-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.model-dropdown:hover {
    background-color: #2f2f2f;
}

.model-name {
    font-weight: 200;
    font-size: 1.1rem;
    color: #ececec;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--icon-color);
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    border-radius: 4px;
    width: 40x;
    height: 40px;
}

.icon-btn:hover {
    background-color: #2f2f2f;
    color: #ececec;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ececec;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 10px 12px;
    border-radius: 8px;
}

.nav-item:hover {
    background-color: #2f2f2f;
}

.nav-text {
    font-weight: 500;
}

.chats-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 8px;
}

.section-header {
    font-size: 0.75rem;
    color: #888;
    font-weight: 600;
    padding: 0 4px;
}

.chat-search {
    display: none;
    align-items: center;
    gap: 8px;
    background-color: var(--sidebar-bg);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 6px 10px;
    margin: 0 8px 12px 8px;
    color: #888;
}

.chat-search.open {
    display: flex;
}

.chat-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    outline: none;
    font-size: 0.9rem;
}

.chat-search i {
    color: #888;
    font-size: 0.9rem;
}

.clear-search {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}

.clear-search:hover {
    color: #ececec;
    background-color: #2f2f2f;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: calc(100% - 10px);
}

.chat-item {
    font-size: 0.9rem;
    color: #ececec;
    padding: 8px 8px;
    cursor: pointer;
    border-radius: 8px;
    padding-left: -50px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item:hover {
    background-color: #2f2f2f;
}

.chat-item.active {
    background-color: #2f2f2f;
    color: #ffffff;
}

.chat-empty {
    padding: 8px;
    color: #888;
    font-size: 0.85rem;
}

.main-content {
    flex: 1;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.main-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.mobile-sidebar-toggle:hover {
    background-color: #2f2f2f;
}

.content-wrapper {
    margin-top: -75px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: none;
    padding: 0 24px;
    position: relative;
}

.greeting {
    font-size: 28px;
    font-weight: 150;
    margin-bottom: 40px;
    color: #ececec;
    text-align: center;
}

.chat-input-container {
    width: min(90%, var(--content-max-width));
    background-color: var(--input-bg);
    border-radius: 27px;
    border: #ffffff0d 0.5px solid;
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    box-shadow: 0px 4px 12px 0px #0000001a,inset 0px 0px 1px 0px #fff3;
    gap: 10px;
    margin: 0 auto;
    position: relative;
    padding-top: 6px;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ececec;
    font-size: 1rem;
    outline: none;
    resize: none;
    overflow-y: hidden;
    font-family: inherit;
    line-height: 1.5;
    padding: 0;
    margin-bottom: 8px; /* Align with buttons visually if needed, or maybe not */
}

.selection-preview {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-left: 0; /* Aligns with padding box, which matches input width roughly */
    margin-bottom: 12px;
    background: #2f2f2f;
    border: 1px solid #3d3d3d;
    border-radius: 18px;
    padding: 12px 16px;
    font-size: 0.95rem;
    color: #e6e6e6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 10;
    animation: fadeIn 0.15s ease-out;
    width: 100%; /* Ensure full width relative to padding box */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.selection-preview.visible {
    display: flex;
}

.selection-preview-icon {
    color: #bfc3c7;
    font-size: 1rem;
    flex-shrink: 0;
}

.selection-preview-body {
    flex: 1;
    font-size: 0.95rem;
    line-height: normal;
    color: #f1f1f1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    padding: 0 4px;
}


.selection-preview-remove {
    background: transparent;
    border: none;
    color: #b4b4b4;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

.selection-preview-remove:hover {
    background: #4b4b4b;
    color: #ffffff;
}

.attach-modal {
    position: absolute;
    background: #1c1c1c;
    border: 1px solid #2f2f2f;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    border-radius: 14px;
    padding: 10px 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    z-index: 90;
    min-width: 210px;
}

.attach-modal.visible {
    display: flex;
}

.attach-option {
    display: flex;
    gap: 10px;
    align-items: center;
    background: transparent;
    border: none;
    color: #e8e8e8;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s ease, transform 0.1s ease;
}

.attach-option i {
    color: #9ad4ff;
}

.attach-option:hover {
    background: #2d2d2d;
    transform: translateY(-1px);
}

.attachment-preview {
    flex: 0 0 100%;
    display: flex;
    align-items: flex-start;
    padding: 4px 4px 6px 8px;
    margin: 0;
}

.attachment-thumb-wrap {
    position: relative;
    display: inline-block;
}

.attachment-thumb-wrap.error .attachment-visual {
    border-color: #ff6b6b;
}

.attachment-visual {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #303030;
}

.attachment-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-icon {
    color: #444;
    font-size: 1.5rem;
}

.attachment-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ffffff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    padding: 0;
    z-index: 5;
}

.attachment-remove:hover {
    background: #eaeaea;
    color: #000;
}

.attachment-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border-radius: 12px;
    z-index: 2;
}

.attachment-overlay.visible {
    opacity: 1;
}

.attachment-spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #333;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

.input-right-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-btn {
    background: transparent;
    border: none;
    color: var(--icon-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.input-btn:hover {
    background-color: #424242;
    color: #ececec;
}

.send-btn {
    background-color: #424242;
    color: var(--icon-color);
    width: 36px;
    height: 36px;
}

.send-btn:disabled {
    background-color: #424242;
    color: #b4b4b4;
    cursor: not-allowed;
}

.send-btn:disabled:hover {
    background-color: #424242;
    color: #b4b4b4;
}

.send-btn:not(:disabled) {
    background-color: #ffffff;
    color: #000000;
    cursor: pointer;
}

.send-btn:not(:disabled):hover {
    background-color: #dcdcdc;
    color: #000000;
}

.user-profile-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}

.user-profile-container:hover {
    background-color: #2f2f2f;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-small img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ececec;
}

.user-status {
    font-size: 0.75rem;
    color: #888;
}

.settings-btn {
    background-color: #2f2f2f;
    border: none;
    color: #ececec;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.settings-btn:hover {
    background-color: #424242;
}

::selection {
    background-color: #555;
    color: #fff;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--sidebar-bg);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 0;
    width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    color: var(--text-color);
    text-align: center;
    overflow: hidden;
}

.settings-modal {
    width: 420px;
    max-width: calc(100% - 32px);
}

.search-modal {
    width: 520px;
    max-width: calc(100% - 32px);
}

.modal-header {
    border-bottom: 1px solid #333;
    padding: 16px 20px;
    text-align: left;
}

.modal-header-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-close {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}

.modal-close:hover {
    background-color: #2f2f2f;
    color: #ececec;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    color: #ececec;
}

.modal-body {
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.search-body {
    padding: 20px;
    align-items: stretch;
    gap: 14px;
    justify-content: flex-start;
    text-align: left;
}

.search-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 10px 12px;
    color: #888;
}

.search-input-row input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    outline: none;
    font-size: 0.95rem;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.search-result-item {
    padding: 10px 12px;
    border: 1px solid #2f2f2f;
    border-radius: 10px;
    cursor: pointer;
    background-color: #1d1d1d;
    transition: border-color 0.15s, background-color 0.15s;
}

.search-result-item:hover {
    border-color: #3a3a3a;
    background-color: #252525;
}

.search-result-title {
    font-weight: 600;
    color: #ececec;
    margin-bottom: 4px;
}

.search-result-meta {
    font-size: 0.8rem;
    color: #888;
}

.search-result-snippet {
    margin-top: 6px;
    font-size: 0.9rem;
    color: #bcbcbc;
    line-height: 1.4;
}

.search-result-snippet .snippet-role {
    color: #8ab4ff;
    margin-right: 6px;
    font-weight: 600;
}

.settings-body {
    padding: 20px;
    align-items: stretch;
    gap: 14px;
    justify-content: flex-start;
    text-align: left;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.9rem;
    color: #c7c7c7;
}

.label-with-icon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.warning-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffc107;
    background: rgba(255, 193, 7, 0.16);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease;
    position: relative;
    vertical-align: middle;
    line-height: 1;
    align-self: center;
    margin-bottom: 1px;
}

.warning-icon.visible {
    opacity: 1;
    transform: scale(1);
}

.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.switch-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.switch-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e5e5e5;
}

.switch-hint {
    font-size: 0.8rem;
    color: #9a9a9a;
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    width: 46px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-track {
    background: #2f2f2f;
    border: 1px solid #555;
    border-radius: 999px;
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    padding: 3px;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.switch-thumb {
    width: 18px;
    height: 18px;
    background: #f5f5f5;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease, background 0.18s ease;
}

.toggle-switch input:checked + .switch-track {
    background: #5a5a5a;
    border-color: #6a6a6a;
}

.toggle-switch input:checked + .switch-track .switch-thumb {
    transform: translateX(20px);
    background: #ffffff;
}

.input-field {
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-color);
    font-size: 0.95rem;
    outline: none;
}

.input-field:focus {
    border-color: #555;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.modal-body p {
    margin-bottom: 6px;
    font-size: 1rem;
    line-height: 1.5;
}

.modal-body p strong {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
    display: block;
}

.modal-button {
    background-color: #2f2f2f;
    border: 1px solid #333;
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 16px;
    transition: background-color 0.2s;
}

.modal-button:hover {
    background-color: #424242;
}

.modal-button.primary {
    background-color: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

.modal-button.primary:hover {
    background-color: #dcdcdc;
}

.modal-button.secondary {
    background-color: transparent;
    color: #ececec;
}
/* Model Dropdown Menu Styles */
.model-dropdown {
    position: relative;
    user-select: none;
}

.model-options-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background-color: var(--input-bg);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 5px 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    margin-top: 5px;
}

.provider-item {
    padding: 8px 12px;
    color: var(--text-color);
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.provider-item:hover {
    background-color: #404040;
}

.provider-item::after {
    content: '';
    font-family: monospace;
    font-weight: bold;
    margin-left: 10px;
}

.provider-submenu {
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 250px;
    max-height: 400px;
    overflow-y: auto;
    background-color: var(--input-bg);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 5px 0;
    margin-left: 5px;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
}

.provider-submenu::-webkit-scrollbar {
    width: 6px;
}
.provider-submenu::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 3px;
}

.model-item {
    padding: 8px 12px;
    color: #ccc;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-item:hover {
    background-color: #404040;
    color: #fff;
}

.model-dropdown.active {
    background-color: #2f2f2f;
}

.provider-item.active {
    background-color: #404040;
}

/* Chat UI Styles */
.chat-history {
    display: none;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    overflow-y: auto;
    flex: 1;
    margin-bottom: 20px;
    scrollbar-width: thin;
}

body.chat-mode .greeting {
    display: none;
}

body.chat-mode .chat-history {
    display: flex;
}

body.chat-mode .content-wrapper {
    margin-top: 60px;
    height: calc(100vh - 60px);
    justify-content: flex-start;
}

body.chat-mode .chat-input-container {
    margin-top: auto;
    margin-bottom: 20px;
}

.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
    max-width: var(--content-max-width);
    margin-left: auto;
    margin-right: auto;
}

.user-message-row {
    justify-content: flex-end;
    flex-direction: column;
    align-items: flex-end;
}

.ai-message-row {
    justify-content: flex-start;
    flex-direction: column;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 1rem;
    position: relative;
    word-wrap: break-word;
}

.message-quote {
    max-width: 80%;
    margin-bottom: 4px;
    color: #888;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 4px; /* Slight buffer */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    /* Optional: add a slight line next to it to look like a reply */
    position: relative;
    user-select: none;
}
.message-quote i {
    font-size: 0.8rem;
    /* transform handled by fa classes */
}

.quote-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-message {
    background-color: #2f2f2f;
    color: #ececec;
    border-top-right-radius: 12px;
}

.ai-message {
    background-color: transparent;
    color: #ececec;
    padding-left: 0;
    max-width: 80%; /* Ensure AI bubble respects the same width */
}

/* AI Action Buttons */
.ai-actions {
    display: flex;
    gap: 8px;
    margin-top: 0px; 
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 0;
}

.ai-message-row:hover .ai-actions {
    opacity: 1;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--icon-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
}

.action-btn:hover {
    background-color: #333;
    color: #ececec;
}

.scroll-to-bottom {
    position: fixed;
    right: 28px;
    bottom: 110px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #3a3a3a;
    background: #1f1f1f;
    color: #ececec;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

.scroll-to-bottom.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-4px);
}

.selection-action-btn {
    position: absolute;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid #3a3a3a;
    background: #1f1f1f;
    color: #ececec;
    font-size: 0.9rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.selection-action-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-2px);
}

.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.message-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: #262626;
    border: 1px solid #303030;
    max-width: 220px;
}

.message-attachment img {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 10px;
}

.message-attachment .file-icon {
    color: #c7c7c7;
    font-size: 1rem;
}

.message-attachment .file-name {
    font-size: 0.85rem;
    color: #eaeaea;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-attachment a {
    color: #eaeaea;
    text-decoration: none;
}

.message-attachment a:hover {
    text-decoration: underline;
}

.send-blocked-popover {
    position: absolute;
    background: #1d1d1d;
    color: #f2f2f2;
    border: 1px solid #303030;
    padding: 8px 10px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
    font-size: 0.9rem;
    z-index: 120;
    max-width: 240px;
    pointer-events: none;
}

/* Markdown Styles */
.markdown-content p {
    margin-bottom: 10px;
}
.markdown-content p:last-child {
    margin-bottom: 0;
}
.markdown-content h1, .markdown-content h2, .markdown-content h3, .markdown-content h4 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}
.markdown-content code {
    background-color: #333;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}
.markdown-content pre {
    background-color: #1e1e1e;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}
.markdown-content pre code {
    background-color: transparent;
    padding: 0;
}
.markdown-content ul, .markdown-content ol {
    margin-left: 20px;
    margin-bottom: 10px;
}
.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}
.markdown-content th, .markdown-content td {
    border: 1px solid #444;
    padding: 8px;
    text-align: left;
}
.markdown-content th {
    background-color: #333;
}
.markdown-content hr {
    border: none;
    border-top: 1px solid #444;
    margin: 20px 0;
}
.markdown-content a {
    color: #58a6ff;
    text-decoration: none;
}
.markdown-content a:hover {
    text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 0;
}

.typing-dot-single {
    width: 12px;
    height: 12px;
    background-color: #ffffff;
    border-radius: 50%;
    animation: typing-pulse 1s ease-in-out infinite;
    opacity: 0.85;
}

@keyframes typing-pulse {
    0% { transform: scale(0.9); opacity: 0.65; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.65; }
}

/* Refresh Popup */
.refresh-popup {
    position: absolute;
    background-color: #2f2f2f;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    min-width: 220px;
}
.refresh-header {
    padding: 8px 10px;
    font-size: 0.8rem;
    color: #888;
    border-bottom: 1px solid #333;
    margin-bottom: 4px;
}
.refresh-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 6px;
    color: #ececec;
    font-size: 0.9rem;
}
.refresh-option:hover {
    background-color: #404040;
}
.refresh-option i {
    width: 16px;
    text-align: center;
    color: #aaa;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    body::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 1100;
    }

    body.sidebar-open::before {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 85vw;
        z-index: 1200;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main-content {
        width: 100%;
    }

    .main-header {
        position: sticky;
        top: 0;
        z-index: 20;
        background-color: var(--bg-color);
        padding: 10px 12px;
    }

    .mobile-sidebar-toggle {
        display: inline-flex;
    }

    .content-wrapper {
        margin-top: 0;
        padding: 0 12px;
    }

    body.chat-mode .content-wrapper {
        margin-top: 0;
        height: calc(100vh - var(--mobile-header-height));
    }

    .greeting {
        margin-bottom: 24px;
        font-size: 24px;
    }

    .chat-input-container {
        width: 100%;
        border-radius: 20px;
        padding: 8px 12px;
    }

    .message-bubble,
    .message-quote,
    .ai-message {
        max-width: 100%;
    }

    .message-row {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .model-name {
        font-size: 0.95rem;
    }

    .greeting {
        font-size: 21px;
    }

    .modal-content {
        width: calc(100% - 20px);
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }

    .settings-modal,
    .search-modal {
        width: calc(100% - 20px);
        max-width: calc(100% - 20px);
    }
}
