* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    min-height: 100vh;
    height: 100vh;
    background: linear-gradient(145deg, #0b0f17 0%, #1a1f2e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    overflow: hidden;
}

/* glassmorphic app container */
.app-container {
    width: 100%;
    max-width: 1600px;
    height: 100%;
    max-height: 98vh;
    background: rgba(20, 25, 40, 0.6);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 36px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), inset 0 1px 2px rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    overflow: hidden;
    transition: all 0.2s ease;
}

/* ---------- SIDEBAR (CHAT HISTORY) ---------- */
.sidebar {
    width: 280px;
    background: rgba(12, 15, 25, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar.collapsed {
    width: 0px;
    min-width: 0px;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 280px;
    padding: 20px 12px;
}

/* new chat button / header */
.new-chat-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 30px;
    padding: 12px 18px;
    color: #eef2fb;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    transition: 0.15s;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

.new-chat-btn:hover {
    background: rgba(80, 100, 180, 0.25);
    border-color: rgba(120, 160, 255, 0.3);
}

.new-chat-btn i {
    font-size: 1.1rem;
    color: #7b9cff;
}

/* history list container */
.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

/* scroll beauty */
.history-list::-webkit-scrollbar {
    width: 4px;
}
.history-list::-webkit-scrollbar-track {
    background: transparent;
}
.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(2px);
    transition: all 0.1s;
    cursor: pointer;
    color: #cdd6f0;
    font-size: 0.9rem;
}

.history-item:hover {
    background: rgba(50, 70, 120, 0.3);
    border-color: rgba(110, 150, 255, 0.25);
}

.history-item .chat-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.history-item .delete-single {
    background: transparent;
    border: none;
    color: #a0b0d0;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: 40px;
    cursor: pointer;
    transition: 0.1s;
}

.history-item .delete-single:hover {
    background: rgba(220, 70, 90, 0.3);
    color: #ffa0a5;
}

/* sidebar footer (settings + delete all) */
.sidebar-footer {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 16px;
}

.footer-btn {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 40px;
    padding: 12px 16px;
    color: #e0e8ff;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.1s;
}

.footer-btn:hover {
    background: rgba(70, 100, 200, 0.2);
}

.footer-btn i {
    width: 22px;
    color: #7b9cff;
}

/* ---------- MAIN CHAT AREA ---------- */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    position: relative;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

/* top bar with burger + model selector */
.top-bar {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
}

.burger {
    font-size: 1.6rem;
    color: #b0c6ff;
    cursor: pointer;
    background: rgba(255,255,255,0.02);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.1s;
    z-index: 101;
}

.burger:hover {
    background: rgba(120, 160, 255, 0.15);
}

.model-selector {
    background: rgba(20, 30, 50, 0.6);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 60px;
    padding: 10px 20px;
    color: #d3e0ff;
    font-weight: 500;
    outline: none;
    backdrop-filter: blur(8px);
    cursor: pointer;
    min-width: 160px;
}

.model-selector option {
    background: #141c2b;
}

/* messages container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px 8px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    height: 100%;
}

.message {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.25s ease;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.bubble {
    padding: 16px 20px;
    border-radius: 28px;
    background: rgba(30, 35, 55, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.03);
    color: #f0f4ff;
    line-height: 1.5;
    font-size: 0.98rem;
    box-shadow: 0 8px 20px -8px rgba(0,0,0,0.5);
    word-break: break-word;
}

.message.user .bubble {
    background: rgba(65, 90, 180, 0.4);
    border: 1px solid rgba(140, 170, 255, 0.25);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .bubble {
    background: rgba(25, 30, 45, 0.7);
    border-bottom-left-radius: 6px;
}

/* markdown content */
.bubble pre {
    background: #0d1422;
    border-radius: 16px;
    padding: 14px;
    overflow-x: auto;
    margin: 12px 0 0;
    position: relative;
}

.bubble code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.bubble p {
    margin: 0 0 8px 0;
}

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

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    color: white;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: 0.1s;
}

.copy-btn:hover {
    background: rgba(100, 140, 255, 0.3);
}

/* typing indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: rgba(40, 45, 65, 0.5);
    border-radius: 40px;
    width: fit-content;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.03);
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: #9bb2ff;
    border-radius: 50%;
    opacity: 0.6;
    animation: blink 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); background: #ccdbff; }
}

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

/* bottom input area */
.input-area {
    padding: 20px 24px 24px 24px;
    background: transparent;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.input-wrapper {
    flex: 1;
    background: rgba(15, 20, 32, 0.7);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 40px;
    display: flex;
    align-items: center;
    padding: 6px 6px 6px 24px;
    transition: border 0.1s;
}

.input-wrapper:focus-within {
    border-color: rgba(140, 180, 255, 0.4);
}

.message-input {
    background: transparent;
    border: none;
    color: #f0f4ff;
    font-size: 1rem;
    width: 100%;
    outline: none;
    padding: 14px 0;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
}

.message-input::placeholder {
    color: #7f8bb0;
}

.action-btn {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    width: 48px;
    height: 48px;
    border-radius: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a7bcff;
    font-size: 1.4rem;
    cursor: pointer;
    transition: 0.1s;
    flex-shrink: 0;
}

.action-btn:hover {
    background: rgba(90, 130, 250, 0.3);
    border-color: rgba(140, 180, 255, 0.3);
    color: white;
}

.action-btn.send-active {
    background: #3860d0;
    color: white;
    border-color: #6b96ff;
}

.action-btn.stop-active {
    background: #a04040;
    color: white;
    border-color: #d06f6f;
}

.attach-btn {
    font-size: 1.3rem;
}

/* settings modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    visibility: hidden;
    opacity: 0;
    transition: 0.2s;
}

.modal-overlay.show {
    visibility: visible;
    opacity: 1;
}

.settings-modal {
    background: rgba(25, 30, 45, 0.95);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 48px;
    width: 450px;
    max-width: 90vw;
    padding: 32px;
    color: #f0f4ff;
    box-shadow: 0 40px 70px -10px black;
}

.settings-modal h2 {
    font-weight: 400;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.setting-row {
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-row label {
    font-size: 0.9rem;
    color: #b6c6ff;
    letter-spacing: 0.3px;
}

.setting-row input, .setting-row select, .setting-row textarea {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 30px;
    padding: 12px 18px;
    color: white;
    outline: none;
    font-size: 0.95rem;
}

.setting-row input[type="range"] {
    padding: 0;
}

.setting-row textarea {
    border-radius: 24px;
    resize: vertical;
}

.modal-close {
    background: #3860d0;
    border: none;
    color: white;
    padding: 14px;
    width: 100%;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 12px;
    cursor: pointer;
}

/* upload preview */
#file-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.preview-item {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-item img {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: cover;
}

/* mobile backdrop */
#sidebar-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(3px);
}

/* Custom glass popup */
.custom-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.custom-popup {
    background: rgba(25, 30, 45, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 32px;
    padding: 28px 32px;
    max-width: 400px;
    width: 90%;
    color: #f0f4ff;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    animation: popupFade 0.2s ease;
}

@keyframes popupFade {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.custom-popup p {
    font-size: 1.1rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.popup-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.popup-btn {
    padding: 12px 24px;
    border-radius: 40px;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.1s;
    background: rgba(255,255,255,0.05);
    color: #e0e8ff;
    border: 1px solid rgba(255,255,255,0.1);
}

.popup-btn.confirm {
    background: #3860d0;
    color: white;
}

.popup-btn.confirm:hover {
    background: #4a7aff;
}

.popup-btn.cancel:hover {
    background: rgba(255,255,255,0.15);
}

/* Thinking block styles */
.thinking-block {
    margin-bottom: 16px;
    border-left: 3px solid #7b9cff;
    background: rgba(30, 40, 60, 0.4);
    border-radius: 12px;
    overflow: hidden;
}

.thinking-block.collapsed .thinking-content {
    display: none;
}

.thinking-block.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.thinking-header {
    padding: 10px 16px;
    background: rgba(50, 70, 120, 0.3);
    color: #b0c6ff;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}

.thinking-header:hover {
    background: rgba(70, 100, 180, 0.4);
}

.thinking-header i {
    font-size: 1rem;
    color: #7b9cff;
}

.toggle-icon {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.thinking-content {
    padding: 16px;
    font-size: 0.95rem;
    color: #d0dcff;
    background: rgba(20, 30, 45, 0.6);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

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

/* Style for thinking text to make it slightly dimmer */
.thinking-content {
    opacity: 0.9;
    font-style: italic;
}

/* Add a subtle pulse animation when thinking is active */
.thinking-header i {
    animation: softPulse 2s infinite;
}

@keyframes softPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Add to style.css */

/* History categories */
.history-category {
    margin-top: 16px;
}

.history-category:first-child {
    margin-top: 0;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    color: #8a9cc0;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 8px;
}

.category-count {
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
}

/* Updated history item styles */
.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    margin-bottom: 4px;
    transition: all 0.1s;
    cursor: pointer;
}

.history-item:hover {
    background: rgba(50, 70, 120, 0.3);
    border-color: rgba(110, 150, 255, 0.25);
}

.history-item.active {
    background: rgba(70, 100, 200, 0.3);
    border-color: rgba(140, 180, 255, 0.4);
}

.history-item-content {
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.chat-name-container {
    flex: 1;
    min-width: 0;
}

.chat-name {
    display: block;
    font-size: 0.9rem;
    color: #e0e8ff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-date-badge {
    display: inline-block;
    font-size: 0.7rem;
    color: #8a9cc0;
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 12px;
}

.history-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.1s;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.edit-single, .delete-single {
    background: transparent;
    border: none;
    color: #a0b0d0;
    font-size: 0.9rem;
    padding: 6px;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-single:hover {
    background: rgba(100, 140, 255, 0.3);
    color: #b0ccff;
}

.delete-single:hover {
    background: rgba(220, 70, 90, 0.3);
    color: #ffa0a5;
}

/* Rename input */
.rename-input {
    background: rgba(20, 30, 50, 0.9);
    border: 1px solid rgba(140, 180, 255, 0.5);
    border-radius: 12px;
    color: white;
    font-size: 0.9rem;
    padding: 6px 10px;
    width: 100%;
    outline: none;
}

.rename-input:focus {
    border-color: #7b9cff;
    box-shadow: 0 0 0 2px rgba(123, 156, 255, 0.2);
}


/* mobile adjustments */
@media (max-width: 700px) {
    body {
        padding: 0;
    }
    
    .app-container { 
        border-radius: 0; 
        height: 100vh;
        max-height: 100vh;
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar { 
        position: absolute; 
        left: 0; 
        top: 0; 
        bottom: 0; 
        z-index: 1000; 
        width: 260px;
        transition: transform 0.25s ease;
        transform: translateX(0);
        box-shadow: 5px 0 30px rgba(0,0,0,0.5);
        border-radius: 0;
    }
    
    .sidebar.collapsed { 
        transform: translateX(-100%);
    }
    
    .burger {
        z-index: 1001;
        background: rgba(20, 25, 40, 0.8);
        backdrop-filter: blur(8px);
    }
    
    .message { 
        max-width: 90%; 
    }
    
    .top-bar {
        padding: 16px;
    }
    
    .input-area {
        padding: 16px;
    }
    
    .messages-container {
        padding: 16px;
    }

    .history-item-actions {
        opacity: 1;
    }
    
    .edit-single, .delete-single {
        padding: 8px;
    }
}