:root {
    --chat-width: 760px;
    --sidebar-width: 260px;
    --border-color: #424242;
    --sidebar-transition-speed: 0.2s;
    --accent-color: #8E7C8E;
    --code-block-color: rgb(44, 44, 44);
    --title-max-width: 300px;
    --main-font: "Google Sans", "Montserrat", sans-serif;

    /* Gap between chat bubbles */
    --bubble-gap: 0px;
    /* Gap between attachments */
    --attachment-gap: 7px;
}

body {
    background-color: #262624;
    margin: 0px;
    display: flex;
    box-sizing: border-box;
    font-family: var(--main-font);
}

*,
*:before,
*:after {
    box-sizing: border-box;
}

button, input, textarea {
    font-family: var(--main-font);
}

/* =========================================
   SIDEBAR
   ========================================= */

#left-sidebar {
    background-color: #252422;
    height: 100vh;
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    border-right: 1px solid var(--border-color);
    transition: width var(--sidebar-transition-speed);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
}

#sidebar-header {
    display: flex;
    align-items: center;
    padding: 10px;
    height: 60px;
    width: 100%;
    flex-shrink: 0;
}

.sidebar-title {
    color: white;
    font-weight: bold;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    width: auto;
    margin-left: 5px;
    transition: color 0.2s, opacity 0.2s ease 0.2s;
    cursor: pointer;
    user-select: none;
}

.sidebar-title:hover {
    color: #e0e0e0;
}

#sidebar-toggle {
    background-color: transparent;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
    transition: background-color 0.2s;
}

#sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#sidebar-toggle svg {
    transition: transform 0.2s ease;
}

#sidebar-toggle:hover svg {
    transform: scale(1.1);
}

#sidebar-toggle:active svg {
    transform: scale(0.95);
}

/* --- NEW CHAT BUTTON --- */
#new-chat {
    background-color: transparent;
    border: none;
    height: 40px;
    margin: 0 10px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    cursor: pointer;
    width: calc(100% - 20px);
    flex-shrink: 0;
}

#new-chat .icon {
    width: 40px;
    height: 40px;
    background-color: var(--accent-color);
    border-radius: 10px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#new-chat .text {
    color: #cecece;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    width: auto;
    margin-left: 10px;
    transition: opacity 0.2s ease 0.2s;
}

#new-chat:hover .text {
    color: white;
}

#new-chat:hover .icon {
    filter: brightness(1.1);
}

/* --- VIEW ALL CHATS BUTTON --- */
#view-all-chats {
    background-color: transparent;
    border: none;
    height: 40px;
    margin: 15px 10px 10px 10px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    cursor: pointer;
    width: calc(100% - 20px);
    flex-shrink: 0;
}

#view-all-chats .icon {
    width: 40px;
    height: 40px;
    background-color: transparent;
    border: none;
    border-radius: 10px;
    color: #cecece;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

#view-all-chats .text {
    color: #cecece;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    width: auto;
    margin-left: 10px;
    transition: opacity 0.2s ease 0.2s;
}

#view-all-chats:hover .text {
    color: white;
}

#view-all-chats:hover .icon {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

/* HOTKEYS */
.hotkey {
    margin-left: auto;
    color: #888;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding-right: 8px;
    font-weight: 500;
}

#new-chat:hover .hotkey,
#view-all-chats:hover .hotkey {
    opacity: 1;
}

/* --- CHAT LIST --- */
#chat-list {
    flex-grow: 1;
    overflow-y: auto;
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Tighter gap */
    min-height: 0;
    padding-bottom: 10px;
}

.chat-item {
    background-color: transparent;
    border: none;
    height: 34px;
    /* Shorter, traditional AI size */
    margin: 0 10px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-radius: 6px;
    width: calc(100% - 20px);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.chat-item:hover,
.chat-item.active {
    background-color: rgba(255, 255, 255, 0.05);
}

.chat-item .title {
    color: #a8a8a8;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity 0.2s ease 0.2s;
    font-weight: 500;
    flex-grow: 1;
    text-align: left;
    padding-right: 5px;
}

.rename-input {
    background: transparent;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 13.5px;
    width: 100%;
    outline: none;
    box-sizing: border-box;
}

.chat-item::selection {
    background: var(--accent-color);
}

/* OPTIONS BUTTON */
.chat-options-btn {
    margin-left: auto;
    width: 24px;
    height: 24px;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.1s, background-color 0.1s;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-item:hover .chat-options-btn,
.chat-item.active .chat-options-btn,
.chat-options-btn:focus {
    opacity: 1;
}

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

/* --- SIDEBAR FOOTER (SETTINGS) --- */
#sidebar-footer {
    margin-top: auto;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

#settings-btn {
    background-color: transparent;
    border: none;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    cursor: pointer;
    width: 100%;
    flex-shrink: 0;
}

#settings-btn .icon {
    width: 40px;
    height: 40px;
    background-color: transparent;
    border-radius: 10px;
    color: #cecece;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s, background-color 0.2s;
}

#settings-btn .text {
    color: #cecece;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    width: auto;
    margin-left: 10px;
    transition: opacity 0.2s ease 0.2s;
}

#settings-btn:hover .text {
    color: white;
}

#settings-btn:hover .icon {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

/* --- COLLAPSED STATE --- */
#left-sidebar.collapsed .sidebar-title,
#left-sidebar.collapsed #new-chat .text,
#left-sidebar.collapsed #view-all-chats .text,
#left-sidebar.collapsed #settings-btn .text {
    opacity: 0;
    width: 0;
    margin: 0;
    pointer-events: none;
    transition: opacity 0s;
}

#left-sidebar.collapsed .hotkey {
    display: none;
}

#left-sidebar.collapsed #chat-list {
    display: none;
}

#left-sidebar.collapsed #new-chat,
#left-sidebar.collapsed #view-all-chats,
#left-sidebar.collapsed #settings-btn {
    width: 40px;
    margin-left: 10px;
}

#left-sidebar.collapsed #sidebar-footer {
    padding: 10px 10px;
}

/* CONTEXT MENU */
.context-menu {
    position: fixed;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    min-width: 140px;
}

.context-menu button {
    background: none;
    border: none;
    color: #ececec;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.context-menu button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.context-menu button.delete-btn {
    color: #ff6b6b;
}

/* =========================================
   SETTINGS MODAL
   ========================================= */

#settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.settings-content {
    background-color: #262624;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 450px;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.settings-header h2 {
    margin: 0;
    font-size: 18px;
    color: white;
}

.settings-header .close-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-header .close-btn:hover {
    color: white;
}

.settings-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 70vh;
    overflow-y: auto;
}

.settings-body label {
    font-size: 13px;
    color: #ccc;
    font-weight: 500;
    margin-bottom: 6px;
    display: block;
}

.settings-body input[type="text"],
.settings-body input[type="password"],
.settings-body textarea {
    width: 100%;
    background-color: #333;
    border: 1px solid #444;
    color: white;
    padding: 10px;
    border-radius: 6px;
    outline: none;
    font-family: var(--main-font);
    font-size: 14px;
    resize: vertical;
}

.settings-body input[type="text"]:focus,
.settings-body input[type="password"]:focus,
.settings-body textarea:focus {
    border-color: #666;
}

/* Color Presets Container */
.color-presets {
    display: flex;
    gap: 12px;
    align-items: center;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s, border-color 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    border-color: white;
    transform: scale(1.1);
}

.settings-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

#settings-save-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: filter 0.2s;
}

#settings-save-btn:hover {
    filter: brightness(1.1);
}

/* =========================================
   ALL CHATS MODAL (Search Style)
   ========================================= */

#all-chats-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.ac-modal-content {
    background-color: #262624;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 680px;
    max-width: 90%;
    height: 550px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.ac-search-header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 60px;
    flex-shrink: 0;
    border-bottom: 1px solid #444;
}

.ac-search-header svg.search-icon {
    color: #888;
    flex-shrink: 0;
}

#ac-search-input {
    flex-grow: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    padding: 0 16px;
    outline: none;
    height: 100%;
}

.header-icon-btn {
    background-color: transparent;
    border: 1px solid transparent;
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
    border-radius: 6px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

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

.header-icon-btn.icon-only {
    padding: 6px;
}

.header-icon-btn.delete-icon {
    color: #ff6b6b;
}

.header-icon-btn.delete-icon:hover {
    background-color: rgba(255, 107, 107, 0.15);
}

.ac-search-header .close-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.ac-search-header .close-btn:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Scrollable List */
#ac-scroll-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px 0;
}

#ac-list {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Chat Row Item */
.ac-row {
    background-color: transparent;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 2px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    transition: background-color 0.2s, border-radius 0.2s;
    position: relative;
}

.ac-row:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.ac-row.selected {
    background-color: rgba(142, 124, 142, 0.15);
}

.ac-row-main {
    flex: 1;
    min-width: 0;
    margin-right: 20px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ac-row-title {
    font-size: 14px;
    font-weight: 500;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: margin-left 0.2s ease;
    margin-left: 0;
}

.ac-row:hover .ac-row-title,
.selecting-mode .ac-row-title {
    margin-left: 28px;
}

.ac-row-preview {
    font-size: 13px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-row-date {
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
    font-family: monospace;
}

/* CHECKBOX */
.ac-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid #666;
    border-radius: 4px;
    position: absolute;
    left: 12px;
    top: 11px;

    opacity: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    flex-shrink: 0;
    transition: opacity 0.2s, border-color 0.2s, background-color 0.2s;
    z-index: 5;
}

.ac-row:hover .ac-checkbox {
    opacity: 1;
    pointer-events: auto;
    border-color: #999;
}

.selecting-mode .ac-checkbox {
    opacity: 1;
    pointer-events: auto;
}

.ac-row.selected .ac-checkbox {
    opacity: 1;
    pointer-events: auto;
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.ac-row.selected .ac-checkbox::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid #262624;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* =========================================
   CHAT & WELCOME SECTION
   ========================================= */

#chat-section {
    flex-grow: 1;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- CHAT HEADER --- */
#chat-header {
    width: 100%;
    height: 60px;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    padding-left: 20px;
    padding-right: 20px;
    background-color: #262624;
    pointer-events: auto;
}

#chat-header-content {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    pointer-events: auto;
}

#chat-header-title {
    font-size: 18px;
    font-weight: bold;
    color: #cecece;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: var(--title-max-width);
    margin-right: 10px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
    user-select: none;
}

#chat-header-title:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.header-rename-input {
    font-size: 18px;
    font-weight: bold;
    color: white;
    background: #262624;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    outline: none;
    width: auto;
    min-width: 150px;
    pointer-events: auto;
}

#chat-header-menu-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    pointer-events: auto;
    flex-shrink: 0;
}

#chat-header-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Main Container */
#chat-container {
    display: flex;
    flex-direction: column;
    gap: 0px;
    padding: 0px 0px 170px 0px;
    color: white;
    width: var(--chat-width);
    margin: 0 auto;
    transition: opacity 0.3s;
    max-width: 100%;
}

body.empty-chat #chat-container {
    opacity: 0;
    pointer-events: none;
}

body.empty-chat #chat-header {
    opacity: 0;
    pointer-events: none;
}

#welcome-screen {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s;
}

body.empty-chat #welcome-screen {
    opacity: 1;
}

#welcome-screen .greeting {
    font-size: 36px;
    font-weight: bold;
    color: var(--accent-color);
    text-shadow: 0 0 7px rgba(0, 0, 0, 0.3);
}

/* =========================================
   PROMPT AREA
   ========================================= */

#prompt-area {
    width: 790px;
    position: fixed;
    bottom: 0px;
    left: var(--sidebar-width);
    right: 0;
    margin: 0 auto 20px auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    background-color: #30302e;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.467), 0px 100px 0px 20px #262624;
    transition: left var(--sidebar-transition-speed), bottom 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 50;
    gap: 0;
}

body.empty-chat #prompt-area {
    top: 40%;
    bottom: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#input-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

#attachment-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

#attachment-preview-container:empty {
    margin-bottom: 0;
}

.preview-card {
    position: relative;
    width: 100px;
    height: 100px;
    background-color: #2F2F2F;
    border: 1px solid #444;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    overflow: hidden;
    cursor: default;
    user-select: none;
    padding: 10px;
}

.preview-card.image-card {
    padding: 0;
    align-items: center;
    justify-content: center;
    background-color: transparent;
}

.preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    border: none;
    margin: 0;
}

.preview-card .file-name {
    font-size: 13px;
    color: #e0e0e0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    margin-bottom: 2px;
}

.preview-card .file-meta-lines {
    font-size: 10px;
    color: #999;
    justify-self: end;
}

.preview-card .file-type-badge {
    align-self: flex-start;
    font-size: 9px;
    color: #cecece;
    border: 1px solid #555;
    padding: 2px 5px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.2);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    font-family: 'Roboto Mono', monospace;
}

.file-type-badge:empty {
    display: none;
}

.preview-card .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 35%;
    background-color: rgba(30, 30, 30, 0.8);
    color: white;
    border: 1px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 10;
}

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

#user-input {
    background-color: transparent;
    outline: none;
    color: white;
    font-size: 16px;
    width: 100%;
    resize: none;
    max-height: 300px;
    overflow-y: hidden;
    line-height: 24px;
    border: none;
    height: 40px;
    min-height: 40px;
    padding: 8px 0 0 2px;
    margin-bottom: none;
}

/* --- VOICE VISUALIZER --- */
#voice-visualizer {
    display: none;
    flex: 1;
    align-items: center;
    min-width: 0;
    margin: 0 8px;
}

#voice-interim-text {
    display: none;
}

#audio-canvas {
    width: 100%;
    height: 36px;
    display: block;
    border-radius: 6px;
}

/* Textarea dimmed during voice recording */
#user-input.voice-active {
    color: rgba(255, 255, 255, 0.35);
    pointer-events: none;
    user-select: none;
}

#controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

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

#attach-btn {
    width: 36px;
    height: 36px;
    background-color: transparent;
    border: none;
    color: #cecece;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: background-color 0.2s, color 0.2s;
}

#attach-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

#model-selector-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#model-selector-btn {
    background-color: transparent;
    border: none;
    color: #cecece;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 13px;
    height: 36px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

#model-selector-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

#model-dropdown {
    position: absolute;
    bottom: 45px;
    right: 0;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 5px;
    display: none;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    min-width: 200px;
    z-index: 1000;
}

#model-dropdown.open {
    display: flex;
}

.model-option {
    background: none;
    border: none;
    color: #ececec;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-option:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.model-option.selected {
    background-color: rgba(142, 124, 142, 0.2);
}

.model-name {
    font-weight: bold;
}

.model-desc {
    font-size: 11px;
    color: #999;
}

/* --- VOICE BUTTONS --- */
#mic-btn {
    width: 36px;
    height: 36px;
    background-color: transparent;
    border: none;
    color: #cecece;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: background-color 0.2s, color 0.2s;
    flex-shrink: 0;
}

#mic-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

#voice-actions {
    display: none;
    align-items: center;
    gap: 8px;
}

#voice-cancel-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: 0.2s;
}

#voice-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

#voice-accept-btn {
    background: var(--accent-color);
    border: none;
    color: white;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: filter 0.2s;
}

#voice-accept-btn:hover {
    filter: brightness(1.1);
}

/* --- SEND BUTTON --- */
#send-btn {
    width: 36px;
    height: 36px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 4px rgb(30, 30, 30);
    transition: opacity 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

#send-btn:hover {
    filter: brightness(1.1);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #444;
}

#send-btn.stop-mode {
    background-color: transparent;
    border: 2px solid var(--border-color);
    box-shadow: none;
}

#send-btn.stop-mode:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.stop-icon-wrapper {
    position: relative;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stop-spinner {
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-top-color: white;
    border-right-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.stop-square {
    width: 8px;
    height: 8px;
    background-color: white;
    border-radius: 1px;
    z-index: 1;
}

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

.loading-dots {
    display: flex;
    gap: 4px;
    padding: 10px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background-color: #888;
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes pulse {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =========================================
   MESSAGES & ATTACHMENTS (Chat View)
   ========================================= */

.message {
    padding: 12px;
    border-radius: 15px;
    word-wrap: break-word;
}

.user-message {
    max-width: 70%;
    align-self: flex-end;
    background-color: var(--accent-color);
    color: white;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.176);
    margin-top: 15px;
    white-space: pre-wrap;
    border-bottom-right-radius: 15px;
}

.ai-message {
    align-self: flex-start;
    background-color: transparent;
    color: white;
    width: 100%;
    padding: 12px 0px;
    box-sizing: border-box;
    position: relative;
    margin-top: 15px;
}

.chat-images-container {
    display: flex;
    flex-direction: column;
    gap: var(--attachment-gap);
    align-self: flex-end;
    align-items: flex-end;
    margin-bottom: var(--attachment-gap);
    max-width: 70%;
    margin-top: 15px;
}

.chat-images-container img {
    max-width: 100%;
    max-height: 250px;
    width: auto;
    object-fit: contain;
    border: 1px solid #444;
    display: block;
    border-radius: 12px;
    border-bottom-left-radius: 12px;
    border-top-left-radius: 12px;
}

.chat-images-container.connected-bottom img:last-child {
    border-bottom-right-radius: 4px;
}

.chat-files-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--attachment-gap);
    align-self: flex-end;
    justify-content: flex-end;
    max-width: 70%;
    margin-bottom: 0;
    margin-top: 15px;
}

.chat-files-container.connected-top {
    margin-top: 0;
}

.chat-files-container.connected-bottom {
    margin-bottom: var(--attachment-gap);
}

.chat-files-container .preview-card {
    background-color: #2F2F2F;
    border: 1px solid #444;
    width: 100px;
    height: 100px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    border-radius: 4px;
}

.chat-files-container .preview-card:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.chat-files-container .preview-card:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.chat-files-container.connected-top .preview-card:last-child {
    border-top-right-radius: 4px;
}

.chat-files-container.connected-bottom .preview-card:last-child {
    border-bottom-right-radius: 4px;
}

.chat-files-container .preview-card .file-meta-lines {
    display: block;
    font-size: 10px;
    color: #aaa;
}

.chat-files-container .preview-card .remove-btn {
    display: none;
}

.user-message.connected-top {
    border-top-right-radius: 4px;
    margin-top: 0;
}

/* =========================================
   MARKDOWN CONTENT STYLING
   ========================================= */

.ai-message p {
    margin: 10px 0;
    line-height: 1.6;
}

.ai-message h1, .ai-message h2, .ai-message h3, .ai-message h4, .ai-message h5, .ai-message h6 {
    color: #fff;
    font-weight: bold;
    margin-top: 24px;
    margin-bottom: 8px;
    line-height: 1.3;
}

.ai-message h1 {
    font-size: 24px;
    border-bottom: 1px solid #444;
    padding-bottom: 6px;
}

.ai-message h2 {
    font-size: 20px;
}

.ai-message h3 {
    font-size: 18px;
}

.ai-message ul, .ai-message ol {
    margin: 8px 0;
    padding-left: 24px;
}

.ai-message li {
    margin: 4px 0;
    line-height: 1.6;
}

.ai-message ul.contains-task-list {
    list-style-type: none;
    padding-left: 0;
}

.ai-message li.task-list-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.ai-message input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--accent-color);
    border-radius: 4px;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    transform: translateY(3.5px);
    margin-top: 0;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.ai-message input[type="checkbox"]:checked {
    background-color: var(--accent-color);
}

.ai-message input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 10px;
    border: solid black;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ai-message blockquote {
    border-left: 4px solid var(--accent-color);
    background-color: rgba(255, 255, 255, 0.05);
    margin: 12px 0;
    padding: 8px 16px;
    color: #cecece;
}

.ai-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
    background-color: rgba(255, 255, 255, 0.02);
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

.ai-message th, .ai-message td {
    border: 1px solid #444;
    padding: 8px 12px;
}

.ai-message th {
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: bold;
}

.ai-message tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.03);
}

.ai-message a {
    color: #aeb4ff;
    text-decoration: none;
}

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

.ai-message img {
    max-width: 100%;
    border-radius: 8px;
    margin: 10px 0;
    border: 1px solid #444;
    display: block;
}

.ai-message :not(pre)>code {
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgb(128, 128, 128);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: rgb(199, 199, 199);
}

.ai-message hr {
    border: none;
    border-top: 1px solid #555;
    margin: 24px 0;
}

.ai-message strong {
    color: #fff;
    font-weight: bold;
}

.ai-message em {
    font-style: italic;
}

/* =========================================
   CUSTOM CODE BLOCKS (Fenced)
   ========================================= */

.code-block-wrapper {
    margin: 15px 0;
    background-color: var(--code-block-color);
    border: 1px solid #444;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.295);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 8.5px 8px 12px;
    background-color: var(--code-block-color);
    user-select: none;
}

.code-lang {
    font-size: 12px;
    color: #cecece;
    text-transform: lowercase;
    font-weight: bold;
}

.code-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.code-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}

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

.code-content {
    position: relative;
    overflow-x: auto;
}

.code-content pre {
    margin: 0;
    padding: 15px;
    background: transparent;
    border: none;
    width: 100%;
    box-sizing: border-box;
    white-space: pre-wrap;
}

.code-content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    background: transparent !important;
}

.code-block-wrapper.collapsed {
    border-radius: 8px;
    height: auto;
}

.code-block-wrapper.collapsed .code-header {
    border-bottom: none;
}

.code-block-wrapper.collapsed .code-content {
    display: none;
}

.collapse-icon {
    transition: transform 0.3s ease;
}

.code-block-wrapper.collapsed .collapse-icon {
    transform: rotate(180deg);
}

.hljs {
    background-color: transparent !important;
    padding: 0 !important;
}

.message-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-start;
    opacity: 1;
    height: auto;
    overflow: visible;
}

.copy-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 5px;
    transition: background-color 0.2s, color 0.2s;
}

.copy-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: white;
}

/* =========================================
   SCROLLBARS & UTILS
   ========================================= */

* {
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-color);
}

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

#chat-header-title {
    min-width: 0;
    flex: 1;
}

#attachment-preview-container {
    min-height: 0;
}