* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; height: 100vh; background: #f5f5f5; }
.hidden { display: none !important; }
.error { color: #e74c3c; margin-top: 8px; font-size: 14px; }

/* Login */
#login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: #1a1a2e; }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 360px; }
.login-box h1 { margin-bottom: 24px; color: #1a1a2e; text-align: center; }
.login-box input { width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.login-box button { width: 100%; padding: 12px; background: #4361ee; color: #fff; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; }
.login-box button:hover { background: #3a56d4; }

/* Chat layout */
#chat-screen { display: flex; height: 100vh; }
#sidebar { width: 260px; background: #1a1a2e; color: #fff; display: flex; flex-direction: column; padding: 16px; }
#new-chat-btn { padding: 10px; background: #4361ee; color: #fff; border: none; border-radius: 6px; cursor: pointer; margin-bottom: 16px; font-size: 14px; }
#conversations-list { flex: 1; overflow-y: auto; }
.convo-item { padding: 10px; border-radius: 6px; cursor: pointer; margin-bottom: 4px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-item { display: flex; align-items: center; }
.convo-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.convo-delete { background: none; border: none; color: #666; font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1; opacity: 0; transition: opacity 0.15s; }
.convo-item:hover .convo-delete { opacity: 1; }
.convo-delete:hover { color: #e74c3c; }
.convo-item:hover, .convo-item.active { background: rgba(255,255,255,0.1); }
#logout-btn { padding: 8px; background: transparent; color: #aaa; border: 1px solid #444; border-radius: 6px; cursor: pointer; margin-top: 8px; }

/* Main chat */
#chat-main { flex: 1; display: flex; flex-direction: column; }
header { padding: 12px 20px; border-bottom: 1px solid #e0e0e0; background: #fff; }
#model-select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; min-width: 300px; }
#messages { flex: 1; overflow-y: auto; padding: 20px; }
.message { max-width: 720px; margin: 0 auto 16px; padding: 12px 16px; border-radius: 8px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.message.user { background: #4361ee; color: #fff; margin-left: auto; margin-right: 0; max-width: 600px; }
.message.assistant { background: #fff; border: 1px solid #e0e0e0; }
#chat-form { display: flex; gap: 8px; padding: 16px 20px; background: #fff; border-top: 1px solid #e0e0e0; }
#prompt-input { flex: 1; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; resize: none; font-family: inherit; }
#send-btn { padding: 12px 24px; background: #4361ee; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; }
#send-btn:disabled { background: #aaa; cursor: not-allowed; }
#optimize-btn { padding: 8px 10px; background: transparent; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; }
#optimize-btn:hover { background: #f0f0f0; }
#optimize-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.metrics { max-width: 720px; margin: -12px auto 16px; padding: 4px 16px; font-size: 11px; color: #888; }