:root {
    --bg: #1e1e2e; --sidebar: #11111b; --panel: #252538; --text: #cdd6f4;
    --accent: #89b4fa; --success: #a6e3a1; --warning: #fab387; --danger: #f38ba8;
    --sidebar-width: 280px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--text); display: flex;
    height: 100vh; height: 100dvh; overflow: hidden;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}

/* Sidebar Layout */
.sidebar {
    width: var(--sidebar-width); background: var(--sidebar); display: flex;
    flex-direction: column; border-right: 1px solid #313244; z-index: 90;
}

.main-workspace {
    flex: 1; display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative;
}

.section-title { padding: 15px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #6c7086; }

.list-item {
    padding: 12px 15px; cursor: pointer; display: flex; justify-content: space-between;
    align-items: center; border-bottom: 1px solid #1e1e2e;
}
.list-item:hover, .list-item.active { background: var(--panel); color: var(--accent); }

.folder-icon { cursor: pointer; margin-left: auto; margin-right: 10px; font-size: 16px; opacity: 0.7; }
.folder-icon:hover { opacity: 1; transform: scale(1.1); }
.delete-chat-btn { color: var(--danger); font-size: 14px; font-weight: bold; padding: 2px 8px; border-radius: 4px; opacity: 0.5; cursor: pointer; }
.delete-chat-btn:hover { opacity: 1; background: rgba(243, 139, 168, 0.2); }

/* Chat Window */
.chat-container { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; display: flex; flex-direction: column; gap: 20px; min-height: 0; }
.message { max-width: 85%; padding: 15px; border-radius: 8px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.message.user { background: var(--panel); align-self: flex-end; border-bottom-right-radius: 2px; }
.message.assistant { background: #313244; align-self: flex-start; border-left: 4px solid var(--accent); border-bottom-left-radius: 2px;}

/* Tool Blocks */
.tool-block { background: #11111b; border: 1px solid #45475a; border-radius: 6px; margin-top: 10px; overflow: hidden; font-family: monospace; width: 100%; }
.tool-header { background: #181825; padding: 10px 12px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #45475a; flex-wrap: wrap; gap: 10px; }
.tool-btn-group { display: flex; gap: 6px; }
.tool-body { padding: 12px; overflow-x: auto; font-size: 13px; color: #fab387; max-height: 300px; }

.go-btn { background: var(--success); color: #11111b; border: none; padding: 6px 14px; font-weight: bold; border-radius: 4px; cursor: pointer; font-size: 12px; }
.go-btn:hover { filter: brightness(1.1); }
.go-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Input Area - Gemini Style */
.input-area { padding: 15px; background: var(--sidebar); display: flex; flex-direction: column; border-top: 1px solid #313244; flex-shrink: 0; padding-bottom: max(15px, env(safe-area-inset-bottom)); position: relative; }

.input-row { display: flex; gap: 10px; align-items: flex-end; z-index: 10; }

textarea { flex: 1; background: var(--panel); border: 1px solid #45475a; border-radius: 25px; color: var(--text); padding: 14px 20px; resize: none; height: 50px; font-family: inherit; font-size: 15px; }
textarea:focus { border-color: var(--accent); outline: none; }

.action-btn {
    background: var(--panel); color: var(--text); border: 1px solid #45475a;
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; transition: transform 0.2s ease, background 0.2s ease;
}
.action-btn:hover { background: #313244; }
.action-btn.active { transform: rotate(45deg); background: var(--accent); color: #11111b; border-color: var(--accent); }

.send-btn { 
    background: var(--accent); color: #11111b; border: none; 
    width: 50px; height: 50px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
}
.send-btn:hover { filter: brightness(1.1); }

/* Action Menu */
.action-menu {
    display: none; flex-direction: column; gap: 15px;
    background: var(--sidebar); border: 1px solid #313244; border-radius: 15px;
    padding: 15px; margin-bottom: 10px;
}
.action-menu.show { display: flex; }

.llm-selector {
    background: #181825; border: 1px solid #45475a; color: var(--accent);
    padding: 10px 15px; border-radius: 8px; font-size: 13px; cursor: pointer; outline: none; width: 100%;
}

/* Settings Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: none; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: var(--bg); width: 90%; max-width: 700px; max-height: 90vh; border-radius: 8px; border: 1px solid #45475a; display: flex; flex-direction: column; }
.modal-header { padding: 15px 20px; border-bottom: 1px solid #313244; display: flex; justify-content: space-between; align-items: center; font-weight: bold; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-close { cursor: pointer; color: var(--danger); font-size: 20px; font-weight: bold; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 12px; color: #a6adc8; }
.form-group input { width: 100%; background: var(--sidebar); border: 1px solid #45475a; color: var(--text); padding: 10px; border-radius: 4px; }

.llm-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; background: var(--sidebar); padding: 10px; border-radius: 4px; border: 1px solid #313244; }
.llm-row input { flex: 1; }
.btn-small { background: var(--panel); color: var(--text); border: 1px solid #45475a; padding: 5px 10px; cursor: pointer; border-radius: 4px; font-size: 12px; }
.btn-small:hover { background: var(--accent); color: #11111b; }

pre { background: #11111b; padding: 10px; border-radius: 5px; overflow-x: auto; margin: 5px 0; }

/* Upload Panel */
.upload-panel { display: flex; flex-wrap: wrap; gap: 15px; align-items: center; font-size: 13px; }
.file-input-wrapper { position: relative; overflow: hidden; display: inline-block; }
.file-btn { border: 1px solid #45475a; color: var(--text); background: #181825; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.file-input-wrapper input[type=file] { font-size: 100px; position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer; }
.sync-checkbox-label { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.file-status-text { color: var(--warning); font-style: italic; word-break: break-all; }

/* Mobile Adjustments */
.mobile-header { display: none; background: var(--sidebar); padding: 10px 15px; align-items: center; justify-content: space-between; border-bottom: 1px solid #313244; position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 50px; }

@media (max-width: 768px) {
    .mobile-header { display: flex; }
    body { flex-direction: column; }
    .sidebar { position: fixed; top: 50px; left: 0; bottom: 0; width: var(--sidebar-width); transform: translateX(-100%); transition: transform 0.3s ease;}
    .sidebar.open { transform: translateX(0); }
    .main-workspace { margin-top: 50px; height: calc(100vh - 50px); height: calc(100dvh - 50px); }
    .tool-header { flex-direction: column; align-items: flex-start; }
    .tool-btn-group { width: 100%; display: flex; gap: 8px; margin-top: 10px; }
    .go-btn { flex: 1; padding: 12px 5px; text-align: center; }
    .upload-panel { flex-direction: column; align-items: flex-start; gap: 8px; }
    .llm-row { flex-direction: column; align-items: stretch; }
    .input-row { gap: 6px; }
    textarea { height: 44px; padding: 12px 15px; }
    .action-btn, .send-btn { width: 44px; height: 44px; }
}