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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
#sidebar {
    width: 260px;
    background: #010409;
    border-right: 1px solid #21262d;
    display: flex;
    flex-direction: column;
    padding: 10px;
    flex-shrink: 0;
}

.sidebar-btn {
    width: 100%;
    padding: 12px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #c9d1d9;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 10px;
}
.sidebar-btn:hover { background: #30363d; }

#chat-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-item:hover { background: #161b22; }
.chat-item.active { background: #1f2937; }
.chat-item .delete-chat {
    display: none;
    background: none;
    border: none;
    color: #f85149;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
}
.chat-item:hover .delete-chat { display: block; }

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid #21262d;
    font-size: 0.75rem;
    color: #8b949e;
    display: flex;
    justify-content: space-between;
}

/* Main */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    scroll-behavior: smooth;
}

.message {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 24px;
}

.message.user {
    background: #161b22;
    border-radius: 12px;
    margin: 8px auto;
    max-width: 760px;
}

.message.assistant {
    padding: 16px 24px;
}

.message .role {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #8b949e;
    margin-bottom: 6px;
}

.message .content {
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message .content pre {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 14px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 0.85rem;
}

.message .content code {
    background: #1f2937;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88rem;
}

.message .content pre code {
    background: none;
    padding: 0;
}

.message .content p { margin: 8px 0; }
.message .content ul, .message .content ol { padding-left: 24px; margin: 8px 0; }
.message .content table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.message .content th, .message .content td { border: 1px solid #30363d; padding: 6px 10px; text-align: left; }
.message .content th { background: #161b22; }
.message .content blockquote { border-left: 3px solid #30363d; padding-left: 12px; color: #8b949e; margin: 8px 0; }
.message .content a { color: #58a6ff; }

/* Input area */
#input-area {
    padding: 16px 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

#file-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.file-tag {
    background: #1f2937;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-tag .remove-file {
    cursor: pointer;
    color: #f85149;
    font-weight: bold;
}

#chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 8px 12px;
}

#upload-btn {
    cursor: pointer;
    color: #8b949e;
    padding: 6px;
    display: flex;
    align-items: center;
}
#upload-btn:hover { color: #c9d1d9; }

#prompt {
    flex: 1;
    background: transparent;
    border: none;
    color: #c9d1d9;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    outline: none;
    height: auto;
    overflow-y: hidden;
}

#send-btn {
    background: #238636;
    border: none;
    border-radius: 8px;
    color: #fff;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
}
#send-btn:hover { background: #2ea043; }
#send-btn:disabled { background: #21262d; cursor: not-allowed; }
#send-btn.hidden, #stop-btn.hidden { display: none; }

/* Typing indicator */
.typing-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: #8b949e;
    border-radius: 50%;
    margin: 0 2px;
    animation: blink 1.4s infinite both;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{opacity:0} 40%{opacity:1} }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* Empty state */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #8b949e;
    font-size: 1.2rem;
}

/* Think blocks */
.think-block {
    border: 1px solid #30363d;
    border-radius: 8px;
    margin: 10px 0;
    background: #0d1117;
}
.think-block summary {
    cursor: pointer;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #8b949e;
    user-select: none;
}
.think-block summary:hover { color: #c9d1d9; }
.think-block .think-content {
    padding: 8px 12px 12px;
    border-top: 1px solid #21262d;
    font-size: 0.85rem;
    color: #8b949e;
    line-height: 1.5;
}

/* Code copy button */
.code-wrapper {
    position: relative;
}
.code-copy {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #8b949e;
    font-size: 0.7rem;
    padding: 3px 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.code-wrapper:hover .code-copy { opacity: 1; }
.code-copy:hover { background: #30363d; color: #c9d1d9; }

/* Stop button */
#stop-btn {
    background: #da3633;
    border: none;
    border-radius: 8px;
    color: #fff;
    padding: 8px 12px;
    cursor: pointer;
    display: none;
    align-items: center;
}
#stop-btn:hover { background: #f85149; }

/* Mobile hamburger */
#mobile-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 100;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #c9d1d9;
    font-size: 1.2rem;
    padding: 6px 10px;
    cursor: pointer;
    line-height: 1;
}

#sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 49;
}

/* Mobile */
@media (max-width: 768px) {
    #mobile-toggle { display: block; }
    #sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 50;
        width: 260px;
        transition: left 0.2s;
    }
    #sidebar.open { left: 0; }
    #sidebar-backdrop.open { display: block; }
    #main { padding-top: 44px; }
    .message { padding: 12px 16px; }
    #input-area { padding: 12px; }
}
