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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --user-bubble: #8b5cf6;
    --assistant-bubble: #2a2a2a;
    --border: #333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

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

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    transition: margin-left 0.3s ease;
}

.sidebar.hidden {
    margin-left: -300px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.sidebar-section select,
.sidebar-section input,
.sidebar-section textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 100%;
}

.sidebar-section select:focus,
.sidebar-section input:focus,
.sidebar-section textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.sidebar-section small {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.env-note {
    color: #10b981 !important;
}

input[type="range"] {
    padding: 0;
    cursor: pointer;
}

.secondary-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
}

.secondary-btn:hover {
    background: #3a3a3a;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.sidebar-footer small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 10px;
    color: var(--text-secondary);
}

.welcome h2 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message.user .avatar {
    background: var(--user-bubble);
}

.message.assistant .avatar {
    background: var(--bg-tertiary);
}

.bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .bubble {
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background: var(--assistant-bubble);
    border-bottom-left-radius: 4px;
}

.bubble pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 0.85rem;
}

.bubble code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9em;
}

.bubble p {
    margin-bottom: 8px;
}

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

.error-bubble {
    background: #3b1c1c;
    color: #fca5a5;
    border: 1px solid #7f1d1d;
}

/* Input */
.input-area {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

#chatForm {
    display: flex;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    font-family: inherit;
}

#userInput:focus {
    outline: none;
    border-color: var(--accent);
}

#sendBtn {
    background: var(--accent);
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

#sendBtn:hover {
    background: var(--accent-hover);
}

#sendBtn:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 100;
        height: 100vh;
    }

    .bubble {
        max-width: 85%;
    }
}
